package com.zhoug.mpchart.core.styleconfig;

import com.zhoug.mpchart.MPChartColors;
import com.zhoug.mpchart.utils.MPChartUtils;

/**
 * @Author: zhoug
 * @Date: 2024-02-07
 * @Description:
 */
public class MPPieStyleConfig extends MPStyleConfig implements IMPPieStyleConfig {
    private int[] pieColors;//颜色


    @Override
    public void setPieColors(int[] pieColors) {
        this.pieColors = pieColors;
    }

    @Override
    public int[] getPieColors() {
        if (pieColors == null || pieColors.length == 0) {
            pieColors = MPChartColors.COLORS;
        }
        return pieColors;
    }

    @Override
    public int getPieColor(int index) {
        return MPChartUtils.getColorForIndex(getPieColors(), index);
    }

    @Override
    public int[] getPieColors(int entryCount) {
        int[] pieColors = getPieColors();
        if (pieColors.length == entryCount) {
            return pieColors;
        }
        return MPChartUtils.createColors(pieColors, entryCount);
    }


}
